from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

task = Tasks.token_classification
model = 'D:\\work\\program\\pytorch_models\\iic\\mgeo_geographic_elements_tagging_chinese_base'
inputs = '我的地址浙江省杭州市余杭区阿里巴巴西溪园区15号楼304'
pipeline_ins = pipeline(
    task=task, model=model)
print(pipeline_ins(input=inputs))
# 输出
# {'output': [{'type': 'prov', 'start': 5, 'end': 8, 'prob': 0.0010394562, 'span': '浙江省'}, {'type': 'city', 'start': 8, 'end': 11, 'prob': 0.00045942832, 'span': '杭州市'}, {'type': 'district', 'start': 11, 'end': 14, 'prob': 0.0005976225, 'span': '余杭区'}, {'type': 'poi', 'start': 14, 'end': 22, 'prob': 0.0004914741, 'span': '阿里巴巴西溪园区'}, {'type': 'houseno', 'start': 22, 'end': 26, 'prob': 0.00061967317, 'span': '15号楼'}]}